SELECT * FROM [acms].[Posts]

Update [acms].[Posts] set GroupingGuid = newId()

declare @tmp table(Id int, ParentId int, NewParentId uniqueidentifier)

insert into @tmp (Id, ParentId)
Select Id, ParentId From [acms].[Posts] 

Update @Tmp
set NewParentId = GroupingGuid
from @Tmp a inner join [acms].[Posts] b on a.ParentId = b.Id

Update [acms].[Posts] 
Set NewParentId = b.NewParentId 
from [acms].[Posts] a inner join @Tmp b on a.Id = b.Id

SELECT * FROM [acms].[Posts]
